import React from 'react'

export default function TodoItem(props) {
    let { item, checkOnetodo, deleteOneTodo } = props;
    //定义事件函数
    let checktodo = (id, done) => {
        // console.log(id);
        // console.log(done)
        //调用
        checkOnetodo(id, done);
    }
    let deletetodo = id => {
        // console.log(id);
        //获取
        // console.log(deleteOneTodo);
        //调用
        deleteOneTodo(id);
    }
    return (
        <li>
            <label>
                <input type="checkbox" checked={item.done} onChange={e => checktodo(item.id, e.target.checked)} />
                <span className={item.done ? 'done' : ''}>{item.title}</span>
            </label>
            <button className="btn btn-danger" onClick={() => deletetodo(item.id)}>删除</button>
        </li>
    )
}
